﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimScripts.BF4Rcon.Test
{
    public class MapDataCreator
    {
        private List<IMap> Maps = new List<IMap>();

        public MapDataCreator AddMaps(params IMap[] maps)
        {
            Maps.AddRange(maps);

            return this;
        }

        public MapDataCreator InsertMaps(int index, params IMap[] maps)
        {
            Maps.InsertRange(index, maps);

            return this;
        }

        public MapDataCreator AddMap(MapName mapName, GameMode gameMode, int rounds)
        {
            Map map = new Map(mapName, gameMode, rounds);

            Maps.Add(map);

            return this;
        }

        public MapDataCreator RemoveMap(int index)
        {
            Maps.RemoveAt(index);

            return this;
        }

        //public MapDataCreator InsertMap(MapName mapName, GameMode gameMode, int rounds, int index)
        //{
        //    Map map = new Map(mapName, gameMode, rounds);
        //    Maps.Insert()
        //}

        public MapDataCreator Clear()
        {
            Maps.Clear();

            return this;
        }

        public int Count { get { return Maps.Count; } }

        public IList<string> GetData(params string[] initialWords)
        {
            return GetData(0, initialWords);
        }

        public IList<string> GetData(int offset, params string[] initialWords)
        {
            List<string> result = new List<string>(initialWords);

            result.Add((Maps.Count - offset).ToString());

            result.Add("3");

            foreach (IMap map in Maps.Skip(offset))
            {
                result.Add(map.RawMapName);
                result.Add(map.RawModeName);
                result.Add(map.RoundsToPlay.ToString());
            }

            return result;
        }
    }
}
